--- 'Monoid' instance for endofunctions
module frege.data.wrapper.Endo where

import Data.Monoid


--- The monoid of endomorphisms under composition.
newtype Endo a = Endo { unwrap :: a -> a }
appEndo = Endo.unwrap

{-- 
    The 'Monoid' instance for 'Endo' has functions as objects, 
    uses '•' as operation and the identity is 'id'. -}
instance Monoid (Endo a) where
    --- > Endo f <> Endo g = Endo (f . g)
    Endo f `mappend` Endo g = Endo (f • g)
    --- > Endo id
    mempty = Endo id
